Traditionally, we package a web application as a WAR file and then deploy it into an external server. Doing this allows us to arrange multiple applications on the same server. When CPU and memory were scarce, this was a great way to save resources.
But things have changed. Computer hardware is fairly cheap now, and the attention has turned to server configuration. A small mistake in configuring the server during deployment may lead to catastrophic consequences.
Spring tackles this problem by providing a plugin, namely spring-boot-maven-plugin, to package a web application as an executable JAR.
To include this plugin, just add a plugin element to pom.xml:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
With this plugin in place, we'll get a fat JAR after executing the package phase. This JAR contains all the necessary dependencies, including an embedded server. So, we no longer need to worry about configuring an external server.
We can then run the application just like we would an ordinary executable JAR.
Notice that the packaging element in the pom.xml file must be set to jar to build a JAR file:
<packaging>jar</packaging>
If we don't include this element, it also defaults to jar.
To build a WAR file, we change the packaging element to war:
<packaging>war</packaging>
and leave the container dependency off the packaged file:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
After executing the Maven package phase, we'll have a deployable WAR file.
Posted Date:- 2021-08-25 05:12:44
What is LiveReload in Spring Boot?
Explain how to register a custom auto-configuration.
How does path=â€sampleâ€, collectionResourceRel=â€sample†work with Spring Data Rest?
In which layer, should the boundary of a transaction start?
What is Spring Boot Starter in Spring Boot Framework?
What things affect what Spring Boot sets up?
What are some common Spring Boot annotations?
What is the difference between Core Spring and Spring Boot?
What is the difference between JPA and Hibernate?
Have you used ActiveMQ in Spring Boot application? Do you know how to configure external ActiveMQ?
What are embedded containers which are supported by Spring Boot?
What is the primary difference between Spring and Spring Boot?
How can you access a value defined in the application? What is properties file in Spring Boot?
What is spring-boot-starter-parent?
How are properties defined? Where?
What is the name of the configuration file which you can use in Spring Boot?
What are the steps to deploy Spring Boot web applications as JAR and WAR files?
Can you use Spring Boot with applications which are not using Spring?
What Does It Mean That Spring Boot Supports Relaxed Binding?
What Are Possible Sources of External Configuration?
What is the process that you need to follow to run Spring Boot application on the custom port?
What is the need for Spring Boot DevTools?
Explain what is thymeleaf and how to use thymeleaf?
What is @Autowired annotation and its usage?
Explain different phases of RAD model.
Explain Spring Actuator and its advantages.
Difference between POST and PUT methods?
What are the types of HTTP methods and Corresponding RestTemplate methods?
What is @ResponseBody annotation?
What is @RequestBody annotation?
What is @Configuration and why is it needed?
How is Spring Boot architecture? Is it the same as Spring MVC?
How can you override default properties in Spring boot Project?
What are disadvantages of Spring boot?
How to Deploy Spring Boot Web Applications as Jar and War Files?
Why did you use Spring boot in your application?
How to create a Spring Boot application using Spring Initializer?